package cn.stylefeng.guns.modular.yingbao.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.yingbao.entity.ContractSetting;
import cn.stylefeng.guns.modular.yingbao.model.params.ContractSettingParam;
import cn.stylefeng.guns.modular.yingbao.service.ContractSettingService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 合约设置表控制器
 *
 * @author jj
 * @Date 2019-12-10 14:16:12
 */
@Controller
@RequestMapping("/contractSetting")
@Api(tags = "合约设置")
public class ContractSettingController extends BaseController {

    private String PREFIX = "/contractSetting";

    @Autowired
    private ContractSettingService contractSettingService;

    /**
     * 跳转到主页面
     *
     * @author jj
     * @Date 2019-12-10
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/contractSetting.html";
    }

    /**
     * 新增页面
     *
     * @author jj
     * @Date 2019-12-10
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/contractSetting_add.html";
    }

    /**
     * 编辑页面
     *
     * @author jj
     * @Date 2019-12-10
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/contractSetting_edit.html";
    }

    /**
     * 新增接口
     *
     * @author jj
     * @Date 2019-12-10
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(ContractSettingParam contractSettingParam) {
        return  this.contractSettingService.add(contractSettingParam);
    }

    /**
     * 编辑接口
     *
     * @author jj
     * @Date 2019-12-10
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(ContractSettingParam contractSettingParam) {

        return this.contractSettingService.update(contractSettingParam);
    }

    /**
     * 删除接口
     *
     * @author jj
     * @Date 2019-12-10
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(ContractSettingParam contractSettingParam) {
        this.contractSettingService.delete(contractSettingParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author jj
     * @Date 2019-12-10
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(ContractSettingParam contractSettingParam) {
        ContractSetting detail = this.contractSettingService.getById(contractSettingParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author jj
     * @Date 2019-12-10
     */
    @CrossOrigin
    @ResponseBody
    @RequestMapping(value = "/applist",method = RequestMethod.POST)
    @ApiOperation("查看区域合约")
    public ResponseData applist() {
        return this.contractSettingService.applist();
    }

    /**
     * 查询列表
     *
     * @author jj
     * @Date 2019-12-10
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(ContractSettingParam contractSettingParam) {
        return this.contractSettingService.findPageBySpec(contractSettingParam);
    }

}


